home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / IE7proSetup_2.3.exe / userscripts / MyspaceNotifier.ieuser.js < prev    next >
Text File  |  2007-11-20  |  6KB  |  130 lines

  1. // ==UserScript==
  2. // @name           Myspace Notifier
  3. // @namespace      http://www.myspace.com/sean_is_a_bamf
  4. // @description    Will notify you of any new mail, friend requests, etc., from anywhere on the 'net.
  5. // @include        *
  6. // ==/UserScript==
  7.  
  8. // Note: You must be logged into myspace for this script to function.
  9. // Using this script might make some internet connections seem slow, this is because
  10. // the myspace homepage is requested every time you load any new page. 
  11. // Configuration Options:
  12.  
  13. (function(){
  14.  messages = true;
  15.  messageIcon = 'http://x.myspace.com/images/icon_envelope.gif';
  16.  friendrequests = true;
  17.  friendrequestIcon = 'http://x.myspace.com/images/icon_envelope.gif';
  18.  comments = true;
  19.  commentIcon = 'http://x.myspace.com/images/icon_envelope.gif';
  20.  imgcomments = true;
  21.  imgcommentIcon = 'http://x.myspace.com/images/icon_envelope.gif';
  22.  blogComments = true;
  23.  blogCommentIcon = 'http://x.myspace.com/images/icon_envelope.gif';
  24.  blogSubscriptions = true;
  25.  blogSubscriptionIcon = 'http://x.myspace.com/images/icon_envelope.gif';
  26.  events = true;
  27.  eventIcon = 'http://x.myspace.com/images/icon_envelope.gif';
  28.  birthdays = true;
  29.  birthdayIcon = 'http://x.myspace.com/images/icon_envelope.gif';
  30.  /* Don't edit anything below unless you know what you're doing */
  31.  function makeRequest() {
  32.      var xmlhttp = PRO_xmlhttpRequest();
  33.      xmlhttp.open("GET", 'http://home.myspace.com/index.cfm?fuseaction=user', true);
  34.      xmlhttp.setRequestHeader('User-agent', 'Mozilla/4.0 (compatible)');
  35.      xmlhttp.setRequestHeader('Accept', 'text/xml');
  36.      xmlhttp.send(null);
  37.      xmlhttp.onreadystatechange = function() {
  38.         if (xmlhttp.readyState == 4) {
  39.             // Store html of the myspace homepage.
  40.             var response = xmlhttp.responseText;
  41.             if(response == '') return;
  42.             // Retrieve the user's friend identifier.
  43.             var r = /friendid=(\d+)"/g.exec(response);
  44.             if(r.length == 1) return;
  45.             var friendid = r[1];
  46.             // Fill in applicable notifications
  47.             var html = '';
  48.             var msgText=/id="indicatorMail" class="(\w+)/g.exec(response)[1];
  49.             var show = 0;
  50.             if(messages && msgText == 'show') {
  51.                 html+= '<a href="http://mail.myspace.com/index.cfm?fuseaction=mail.inbox"><img src="'+messageIcon+'"> New Messages</a><br />';
  52.                 show = 1;
  53.             }
  54.             var reqText=/id="indicatorFriendRequest" class="(\w+)/g.exec(response)[1];
  55.             if(friendrequests && reqText == 'show') {
  56.                 html+= '<a href="http://mail.myspace.com/index.cfm?fuseaction=mail.friendRequests"><img src="'+friendrequestIcon+'"> New Friend Requests</a><br />';
  57.                 show = 1;
  58.             }
  59.             var comText=/id="indicatorComments" class="(\w+)/g.exec(response)[1];
  60.             if(comments && comText == 'show') {
  61.                 html+= '<a href="http://comments.myspace.com/index.cfm?fuseaction=user.HomeComments&friendID='+friendid+'"><img src="'+commentIcon+'"> New Comments</a><br />';
  62.                 show = 1;
  63.             }
  64.             var imgText=/id="indicatorImageComments" class="(\w+)/g.exec(response)[1];
  65.             if(imgcomments && imgText == 'show') {
  66.                 html+= '<a href="http://viewmorepics.myspace.com/index.cfm?fuseaction=user.viewPicture&friendID='+friendid+'"><img src="'+imgcommentIcon+'"> New Picture Comments</a><br />';
  67.                 show = 1;
  68.             }
  69.             var bcomText=/id="indicatorBlogComments" class="(\w+)/g.exec(response)[1];
  70.             if(blogComments && bcomText == 'show') {
  71.                 html+= '<a href="http://blog.myspace.com/index.cfm?fuseaction=blog.controlcenter"><img src="'+blogCommentIcon+'"> New Blog Comments</a><br />';
  72.                 show = 1;
  73.             }
  74.             var blogText=/id="indicatorBlogs" class="(\w+)/g.exec(response)[1];
  75.             if(blogSubscriptions && blogText == 'show') {
  76.                 html+= '<a href="http://blog.myspace.com/index.cfm?fuseaction=blog.controlcenter"><img src="'+blogSubscriptionIcon+'"> New Blog Subscription Posts</a><br />';
  77.                 show = 1;
  78.             }
  79.             var eventText=/id="indicatorEvents" class="(\w+)/g.exec(response)[1];
  80.             if(events && eventText == 'show') {
  81.                 html+= '<a href="http://mail.myspace.com/index.cfm?fuseaction=mail.eventInvite"><img src="'+eventIcon+'"> New Event Invitation</a><br />';
  82.                 show = 1;
  83.             }
  84.             var bdayText=/id="indicatorBirthday" class="(\w+)/g.exec(response)[1];
  85.             if(birthdays && bdayText == 'show') {
  86.                 html+= '<a href="http://collect.myspace.com/index.cfm?fuseaction=user.birthdays&friendID='+friendid+'"><img src="'+birthdayIcon+'"> New Birthdays</a><br />';
  87.                 show = 1;
  88.             }
  89.             if(show == 1) {
  90.                 // Create notifier element.
  91.                 var notifier = document.createElement('div');
  92.                 notifier.setAttribute('id', 'GM_MSNotify');
  93.                 document.body.appendChild(notifier);
  94.  
  95.                 notifier.innerHTML = html;
  96.  
  97.                 // Apply some custom CSS to the notifier element.
  98.                 PRO_addStyle('#GM_MSNotify {' +
  99.                         'display:block!important;' +
  100.                         //FIXME for IE
  101.                         //'position:fixed!important;' +
  102.                         'position:absolute!important;' +
  103.                         'top:0!important;' +
  104.                         'left:0!important;' +
  105.                         'z-index:9999!important;' +
  106.                         'width:150px!important;' +
  107.                         'background-color:#000000!important;' +
  108.                         'opacity:80.0!important;' +
  109.                         'text-align:left!important;' +
  110.                         '-moz-border-radius:0 0px 10 10!important;' +
  111.                         'padding:3px!important;}' +
  112.                         '#GM_MSNotify a {' +
  113.                         'display:inline!important;' +
  114.                         'color:#FFF!important;' +
  115.                         'text-decoration:none!important;' +
  116.                         'line-height:8px;' +
  117.                         'font:bold 10px Century Gothic, serif!important;}' +
  118.                         '#GM_MSNotify br {display:inline!important}' +
  119.                         '#GM_MSNotify img {width:12px!important;opacity:1!important;border:none!important}'
  120.                         );
  121.             }
  122.         }
  123.     }
  124.  }
  125.  // Make sure we're not in a frame's body, then execute script.
  126.  if(top.location == location) {
  127.      makeRequest();
  128.  }
  129. })();
  130.